package org.lib.data.user.api.feign;

import org.lib.data.user.api.constant.AppConstant;
import org.lib.data.user.api.dto.AddUserDTO;
import org.lib.data.user.api.dto.UpdateUserDTO;
import org.lib.data.user.api.vo.UserVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 用户接口
 * @author ben
 * @date 2021-08-30 22:34:15 CST
 */
//@FeignClient(name = AppConstant.S_DATA_USER, fallback = UserFeignFallback.class)
@FeignClient(name = AppConstant.S_DATA_USER, fallbackFactory = UserFeignFallbackFactory.class)
public interface UserFeign {

	/**
	 * 添加用户
	 * @author ben
	 * @date 2021-08-30 22:33:59 CST
	 * @param dto
	 * @return
	 */
	@PostMapping(value="/user/add")
	public Long addUser(@RequestBody AddUserDTO dto);
	
	/**
	 * 查询用户
	 * @author ben
	 * @date 2021-09-02 15:41:00 CST
	 * @param id
	 * @return 查询到，返回用户；否则，返回null
	 */
	@GetMapping(value="/user/get")
	public UserVO getUser(@RequestParam Long id);

	/**
	 * 根据手机号查询用户
	 * @author ben
	 * @date 2021-09-02 21:57:00 CST
	 * @param email
	 * @return
	 */
	@GetMapping(value="/user/getByEmail")
	public UserVO getUserByEmail(@RequestParam String email);
	
	/**
	 * 根据手机号查询用户
	 * @author ben
	 * @date 2021-09-02 21:57:05 CST
	 * @param phone
	 * @return
	 */
	@GetMapping(value="/user/getByPhone")
	public UserVO getUserByPhone(@RequestParam String phone);

	/**
	 * 删除用户
	 * @author ben
	 * @date 2021-09-02 15:41:27 CST
	 * @param id
	 * @return 执行后，用户不存在时返回false
	 */
	@PostMapping(value="/user/del")
	public Boolean delUser(@RequestParam Long id);

	/**
	 * 更新用户
	 * 包括更密码
	 * @author ben
	 * @date 2021-09-02 22:35:25 CST
	 * @param dto
	 * @return
	 */
	@PostMapping(value="/user/update")
	UserVO updateUser(@RequestBody UpdateUserDTO dto);
	
}
